<?php
$protect_admin = true;
include "../includes/fun.global.php";
if (!empty($_QET['login'])) {
    setcookie("THEKEY", null, time() - 3600 * 12 * 15, '/');
    setcookie("THEKEY", $_QET['login'], time() + 3600 * 12 * 15, '/');
    header("Location:" . is_https(false) . href() . "/user/login.php");
}

use Medoo\DB\SQL;

global $title, $cdnserver, $tise;
$DBrE = SQL::DB();
$CountN = $DBrE->count('tickets', [
    'state[!]' => 3,
    'type[<]' => 3
]);
$CountN2 = $DBrE->count('mark', [
    'state' => 2
]);
$CountN3 = $DBrE->count('withdrawal', [
    'state' => 3
]);
$Official = is_file(ROOT . 'includes/lib/soft/controller/Official/index.php'); //服务端对接插件
$Mailnotify = is_file(ROOT . 'includes/lib/soft/controller/Mailnotify/index.php'); //邮件发送插件
$WebsiteMaintenance = is_file(ROOT . 'includes/lib/soft/controller/WebsiteMaintenance/index.php'); //网站维护插件
?>
<!DOCTYPE html>
<html lang="cn">

<head>
    <meta charset="utf-8"/>
    <title><?= $title ?></title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="shortcut icon" href="<?= $cdnserver == null ? '../' : $cdnserver ?>assets/favicon.ico">
    <link href="<?= $cdnserver == null ? '../' : $cdnserver ?>assets/css/vendor/jquery-jvectormap-1.2.2.css"
          rel="stylesheet" type="text/css"/>
    <link rel="stylesheet" type="text/css"
          href="<?= $cdnserver == null ? '../' : $cdnserver ?>assets/layui/css/layui.css"/>
    <link rel="shortcut icon" href="<?= $cdnserver == null ? '../' : $cdnserver ?>assets/favicon.ico"
          type="image/x-icon"/>
    <link href="<?= $cdnserver == null ? '../' : $cdnserver ?>assets/css/icons.min.css" rel="stylesheet"
          type="text/css"/>
    <link href="<?= $cdnserver == null ? '../' : $cdnserver ?>assets/css/app.min.css" rel="stylesheet" type="text/css"/>
</head>
<style>
    .card-title {
        font-weight: 300;
    }

    ;
</style>

<body>
<!-- Begin page -->
<div class="wrapper">
    <!-- ========== Left Sidebar Start ========== -->
    <div class="left-side-menu" style="z-index: 10;">
        <div class="slimscroll-menu" id="left-side-menu-container">
            <!-- LOGO -->

            <!--- Sidemenu -->
            <ul class="metismenu side-nav">

                <li class="side-nav-title side-nav-item" style="font-size: 2em;color: white;font-weight: 300">站长后台
                </li>

                <li class="side-nav-item">
                    <a href="index.php" class="side-nav-link">
                        <i class="layui-icon layui-icon-home"></i>
                        <span> 数据中心 </span>
                    </a>
                </li>

                <li class="side-nav-item">
                    <a href="javascript: void(0);" class="side-nav-link">
                        <i class="layui-icon layui-icon-rate-solid"></i>
                        <span> 推荐插件 <?= ($Official !== false && $Mailnotify !== false && $WebsiteMaintenance !== false ? '' : '<span class="layui-badge-dot"></span>') ?></span>
                        <span class="menu-arrow"></span>
                    </a>
                    <ul class="side-nav-second-level" aria-expanded="false">
                        <li>
                            <a href="javascript:<?= $Official ? 'Hover.Open(\'Official\',\'官方货源对接\')' : 'layer.alert(\'支持一键对接串货,官方服务端货源站!,扩展商品数量,供货商均缴纳了对应押金,货源安全有保障,可打开应用商店安装插件!\',{icon:1})' ?>">官方货源对接</a>
                        </li>
                        <li>
                            <a href="javascript:<?= $Mailnotify ? 'Hover.Open(\'Mailnotify\',\'邮件通知插件\')' : 'layer.alert(\'支持用户卡密商品购买通知,提现通知,注册通知,新订单购买通知等,非常完善,强烈推荐,可打开应用商店安装插件!\',{icon:1})' ?>">邮件通知插件</a>
                        </li>
                        <li>
                            <a href="javascript:<?= $WebsiteMaintenance ? 'Hover.Open(\'WebsiteMaintenance\',\'网站维护插件\')' : 'layer.alert(\'用于解决网站的各种问题,如支付接口,网站配置无法保存,订单清空,公告清空等!,支持在线备份数据库,保存至服务端,防止数据丢失,可打开应用商店安装插件!\',{icon:1})' ?>">网站维护插件</a>
                        </li>
                    </ul>
                </li>

                <li class="side-nav-item">
                    <a href="javascript: void(0);" class="side-nav-link">
                        <i class="layui-icon layui-icon-cart"></i>
                        <span> 商品管理 <?= ($CountN2 == 0 ? '' : '<span class="layui-badge-dot"></span>') ?></span>
                        <span class="menu-arrow"></span>
                    </a>
                    <ul class="side-nav-second-level" aria-expanded="false">
                        <li>
                            <a href="admin.goods.add.php">添加商品</a>
                        </li>
                        <li>
                            <a href="admin.goods.list.php">商品列表</a>
                        </li>
                        <li>
                            <a href="admin.goods.sort.php">商品排序</a>
                        </li>
                        <li>
                            <a href="admin.goods.rank.php">热销排行</a>
                        </li>
                        <li>
                            <a href="admin.class.list.php">商品分类</a>
                        </li>
                        <li>
                            <a href="admin.discuss.list.php">评论审核 <?= ($CountN2 == 0 ? '' : '<span class="layui-badge layui-bg-red">' . $CountN2 . '</span>') ?></a>
                        </li>
                    </ul>
                </li>

                <li class="side-nav-item">
                    <a href="javascript: void(0);" class="side-nav-link">
                        <i class="layui-icon layui-icon-gift"></i>
                        <span> 活动推广</span>
                        <span class="menu-arrow"></span>
                    </a>
                    <ul class="side-nav-second-level" aria-expanded="false">
                        <li>
                            <a href="admin.coupon.list.php">券码引流</a>
                        </li>
                        <li>
                            <a href="javascript:layer.msg('未开放,敬请期待')">拼团引流</a>
                        </li>
                        <li>
                            <a href="javascript:layer.msg('未开放,敬请期待')">砍价引流</a>
                        </li>
                    </ul>
                </li>

                <li class="side-nav-item">
                    <a href="javascript: void(0);" class="side-nav-link">
                        <i class="layui-icon layui-icon-transfer"></i>
                        <span> 订单管理 <?= ($CountN == 0 ? '' : '<span class="layui-badge-dot"></span>') ?></span>
                        <span class="menu-arrow"></span>
                    </a>
                    <ul class="side-nav-second-level" aria-expanded="false">
                        <li>
                            <a href="admin.order.list.php">订单列表</a>
                        </li>

                        <li>
                            <a href="tickets.php">售后工单 <?= ($CountN == 0 ? '' : '<span class="layui-badge layui-bg-red">' . $CountN . '</span>') ?></a>
                        </li>
                    </ul>
                </li>

                <li class="side-nav-item">
                    <a href="javascript: void(0);" class="side-nav-link">
                        <i class="layui-icon layui-icon-cols"></i>
                        <span> 货源管理 </span>
                        <span class="menu-arrow"></span>
                    </a>
                    <ul class="side-nav-second-level" aria-expanded="false">
                        <li>
                            <a href="admin.source.list.php">货源列表</a>
                        </li>
                        <li>
                            <a href="admin.goods.token.php">卡密库存</a>
                        </li>
                    </ul>
                </li>

                <li class="side-nav-item">
                    <a href="javascript: void(0);" class="side-nav-link">
                        <i class="layui-icon layui-icon-username"></i>
                        <span> 用户管理 <?= ($CountN3 == 0 ? '' : '<span class="layui-badge-dot"></span>') ?></span>
                        <span class="menu-arrow"></span>
                    </a>
                    <ul class="side-nav-second-level" aria-expanded="false">
                        <li>
                            <a href="admin.user.set.php">基础配置</a>
                        </li>
                        <li>
                            <a href="admin.user.list.php">用户列表</a>
                        </li>
                        <li>
                            <a href="admin.level.list.php">等级管理</a>
                        </li>
                        <li>
                            <a href="admin.user.log.php">用户日志</a>
                        </li>

                        <li>
                            <a href="admin.user.pay.php">提现管理 <?= ($CountN3 == 0 ? '' : '<span class="layui-badge layui-bg-red">' . $CountN3 . '</span>') ?></a>
                        </li>
                    </ul>
                </li>

                <li class="side-nav-item">
                    <a href="javascript: void(0);" class="side-nav-link">
                        <i class="layui-icon layui-icon-read"></i>
                        <span> 文章管理 </span>
                        <span class="menu-arrow"></span>
                    </a>
                    <ul class="side-nav-second-level" aria-expanded="false">
                        <li>
                            <a href="admin.article.list.php">文章列表</a>
                        </li>
                        <li>
                            <a href="admin.article.add.php">发布文章</a>
                        </li>
                    </ul>
                </li>
                <li class="side-nav-item">
                    <a href="javascript: void(0);" class="side-nav-link">
                        <i class="layui-icon layui-icon-template-1"></i>
                        <span> 便捷模块</span>
                        <span class="menu-arrow"></span>
                    </a>
                    <ul class="side-nav-second-level" aria-expanded="false">
                        <li>
                            <a href="admin.goods.express.php">运费模板</a>
                        </li>

                        <li>
                            <a href="admin.InputValidation.php">输入验证</a>
                        </li>

                        <li>
                            <a href="admin.FilePower.php">权限管理</a>
                        </li>
                    </ul>
                </li>

                <li class="side-nav-item">
                    <a href="javascript: void(0);" class="side-nav-link">
                        <i class="layui-icon layui-icon-set"></i>
                        <span> 站点设置 </span>
                        <span class="menu-arrow"></span>
                    </a>
                    <ul class="side-nav-second-level" aria-expanded="false">
                        <li>
                            <a href="admin.notice.set.php">公告设置</a>
                        </li>
                        <li>
                            <a href="admin.app.set.php">网站编辑</a>
                        </li>
                        <li>
                            <a href="admin.template.set.php">首页模板</a>
                        </li>
                        <li>
                            <a href="admin.Payments.php">支付配置</a>
                        </li>
                        <li>
                            <a href="admin.sms.set.php">短信配置</a>
                        </li>
                        <li>
                            <a href="admin.cart.set.php">购物车</a>
                        </li>
                        <li>
                            <a href="admin.laboratory.set.php">实验室</a>
                        </li>
                    </ul>
                </li>
                <li class="side-nav-item">
                    <a href="admin.store.php" class="side-nav-link">
                        <i class="layui-icon layui-icon-component"></i>
                        <span> 应用商店 </span>
                    </a>
                </li>
                <li class="side-nav-item">
                    <a href="?Loggedout=1" class="side-nav-link">
                        <i class="layui-icon layui-icon-logout"></i>
                        <span> 退出登陆 </span>
                    </a>
                </li>
            </ul>
        </div>
        <!-- Sidebar -left -->
    </div>
    <!-- Left Sidebar End -->
    <div class="content-page">
        <div class="content">
            <!-- Topbar Start -->
            <div class="navbar-custom">
                <ul class="list-unstyled topbar-right-menu float-right mb-0">
                    <li class="dropdown notification-list">
                        <a class="nav-link dropdown-toggle arrow-none" data-toggle="dropdown" href="#" role="button"
                           aria-haspopup="false" aria-expanded="false">
                            <i class="layui-icon layui-icon-email noti-icon"></i>
                            <span class="noti-icon-badge"></span>
                        </a>
                        <div class="dropdown-menu dropdown-menu-right dropdown-menu-animated dropdown-lg">

                            <!-- item-->
                            <div class="dropdown-item noti-title">
                                <h5 class="m-0">
                                    官方通知
                                </h5>
                            </div>
                            <div class="slimscroll" style="max-height: 230px;" id="message"></div>
                        </div>
                    </li>

                    <li class="dropdown notification-list">
                        <a class="nav-link dropdown-toggle nav-user arrow-none mr-0" data-toggle="dropdown" href="#"
                           role="button" aria-haspopup="false" aria-expanded="false">
                                <span class="account-user-avatar">
                                    <img id="head_image" src="../assets/img/image_index.png" alt="user-image"
                                         class="rounded-circle bg-warning" style="border: solid 2px #ccc">
                                </span>
                            <span>
                                    <span class="account-user-name">Super</span>
                                    <span class="account-position" id="header_name">站长</span>
                                </span>
                        </a>
                        <div class="dropdown-menu dropdown-menu-right dropdown-menu-animated topbar-dropdown-menu profile-dropdown">
                            <!-- item-->

                            <div class=" dropdown-header noti-title">
                                <h6 class="text-overflow m-0">快捷导航</h6>
                            </div>

                            <!-- item-->
                            <a href="javascript:void(0);" target="_blank" class="dropdown-item notify-item group">
                                <i class="layui-icon layui-icon-chat mr-1"></i>
                                <span>联系官方</span>
                            </a>

                            <!-- item-->
                            <a href="admin.user.list.php" class="dropdown-item notify-item">
                                <i class="layui-icon layui-icon-user mr-1"></i>
                                <span>用户管理</span>
                            </a>
                            <!-- item-->
                            <a href="../" target="_blank" class="dropdown-item notify-item">
                                <i class="layui-icon layui-icon-home mr-1"></i>
                                <span>前往首页</span>
                            </a>
                            <!-- item-->
                            <a href="?Loggedout=1" class="dropdown-item notify-item">
                                <i class="layui-icon layui-icon-logout mr-1"></i>
                                <span>注销账号</span>
                            </a>

                        </div>
                    </li>

                </ul>
                <button class="button-menu-mobile open-left disable-btn">
                    <i class="layui-icon layui-icon-spread-left"></i>
                </button>
                <div class="app-search">
                    <form>
                        <div class="input-group">
                            <input type="text" class="form-control" id="dw" placeholder="输入下单信息搜索订单">
                            <span class="layui-icon layui-icon-search"></span>
                            <div class="input-group-append">
                                <button class="btn btn-primary"
                                        onclick="window.location.href='admin.order.list.php?val='+$('#dw').val()"
                                        type="button">搜索
                                </button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
            <!-- end Topbar -->
            <!-- start page title -->
            <div class="row AppOn" style="width: 98%;margin: auto">
                <div class="col-12">

                    <?php if ($tise == 'index') { ?>

                        <div class="page-title-box">
                            <div class="page-title-right">
                                <form class="form-inline">
                                    <div class="form-group">
                                        <div class="input-group">
                                            <input type="text" class="form-control form-control-light"
                                                   id="dash-daterange">
                                            <div class="input-group-append">
                                                    <span class="input-group-text bg-primary border-primary text-white">
                                                        <i class="layui-icon layui-icon-search font-13"></i>
                                                    </span>
                                            </div>
                                        </div>
                                    </div>
                                </form>
                            </div>
                            <h4 class="page-title"><?= $title ?></h4>
                        </div>

                    <?php } else { ?>
                        <!-- start page title -->
                        <div class="row">
                            <div class="col-12">
                                <div class="page-title-box">
                                    <div class="page-title-right">
                                        <ol class="breadcrumb m-0">
                                            <li class="breadcrumb-item"><a href="index.php">首页</a></li>
                                            <li class="breadcrumb-item active"><?= $title ?></li>
                                        </ol>
                                    </div>
                                    <h4 class="page-title"><?= $title ?></h4>
                                </div>
                            </div>
                        </div>
                        <!-- end page title -->
                    <?php } ?>
                </div>
            </div>
            <!-- end page title -->
            <style>
                .note-popover {
                    display: none
                }

                .note-toolbar {
                    z-index: 9 !important;
                }

                .panel-heading {
                    border-bottom: 1px solid #ccc;
                }
            </style>